const { app, BrowserWindow } = require('electron')
const path = require('path')
const createWindow = () => {
    const win = new BrowserWindow({
      width: 800,
        height: 600,
      webPreferences: {
        'plugins': true,
        webSecurity: false,
            preload: path.join(__dirname, 'preload.js')
          }
    })
  
    win.loadFile('index.html')
}
app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') app.quit()
})
app.whenReady().then(() => {
    createWindow()
  
    app.on('activate', () => {
      if (BrowserWindow.getAllWindows().length === 0) createWindow()
    })
})
//获取系统默认的flash.dll
let pepflashplayer = app.getPath('pepperFlashSystemPlugin');
console.log(pepflashplayer);
if (process.platform == "win32") {
  if (process.arch == 'x64') {
    //加载项目提供的flash.dll
    pepflashplayer = path.join(__dirname, '../Flash/pepflashplayer64_23_0_0_162.dll');//开发环境的路径
    if (__dirname.includes(".asar")) {
      pepflashplayer = path.join(process.resourcesPath+'/Flash/pepflashplayer64_23_0_0_162.dll');//运行环境的路径
    }
    //console.log(pepflashplayer);
  } else {
    //32位的自己补充
  }
} else {
  //其他系统环境
}
app.commandLine.appendSwitch('ppapi-flash-path',pepflashplayer);